//
//  GridLayout.swift
//  CollectionView
//
//  Created by SuXinDe on 2019/2/21.
//  Copyright © 2019 su xinde. All rights reserved.
//

import UIKit

class GridLayout: UICollectionViewFlowLayout {
    init(width: CGFloat) {
        super.init()
        let col: Int = 4
        let itemSpacing: CGFloat = 1.5
        let columnsAsFloat = CGFloat(col)
        let itemLength: CGFloat = (width - (columnsAsFloat - 1.0) * itemSpacing) / columnsAsFloat
        itemSize = CGSize(width: itemLength, height: itemLength)
        minimumInteritemSpacing = itemSpacing
        minimumLineSpacing = itemSpacing
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
